/*
 This file 'zdwxy_1' is part of Firebird Integrated Solution 1.0

 Copyright (c) 2020 Lincong

 Contact:  
        Email: lincong1987@gmail.com

        QQ: 159257119
 
 See Usage at http://www.jplatformx.com/firebird

 Create date: 2020-06-14 20:49
 */

define(function (require, exports, module) {

	require("../model/Chart");

	var ArrayUtils = require("../assets/ArrayUtils");

	var china = require("../assets/map/json/china.json");

	var mapName = "china";
	
	echarts.registerMap(mapName, china);

	var id = "zdwxy_7";

	Firebird.define(id, {
		extend: "Chart",
		setValue: function (data) {




			// 散点数据结构
			//  [
			//  {
			// 					name: "杭州市",
			// 					value: [n.properties.cp[0], n.properties.cp[1], 作业总数, 绿码数, 黄码数, 蓝码],
			// 				}
			//  ]
			// data = zhejiang.features.map(function (n, index) {
			// 	return {
			// 		name: n.properties.name,
			// 		value: [n.properties.cp[0], n.properties.cp[1], 100 + index, 100, 100, 100, 100],
			// 	};
			// });


			// data =

			var option = {


				tooltip: {
					show: true,
					formatter: function (node) {
						if (node.seriesName === "气泡") {
							// + "" + node.name + ":" + node.value[2] +
							return "<div  style='background: rgba(9, 51, 166, 1); padding: 4px 8px;'>"

								+ "<div>" + node.name + "</div>" + "</div>";


						}
					}
				},

				geo: [
					{
						show: true,
						map: mapName,
						animation: false,
						label: {
							show: false,
						},
						roam: false,
						itemStyle: {
							borderColor: "rgba(206, 255, 254, 1)",
							borderWidth: 3,
							shadowColor: 'rgba(0, 192, 255, 0.6)',
							shadowBlur: 20,
							shadowOffsetX: 0,
							shadowOffsetY: 0
						},
						emphasis: {
							label: {
								show: false,
							}
						},
						zlevel: 0,
						z: 0,
						aspectScale: null,
						zoom: 1.1
					}
				],

				series: [
					{
						type: "map",
						show: true,
						zoom: 1.1,
						map: mapName,
						roam: false,
						label: {
							show: false,
							color: "#fff",
							fontSize: 16,
						},
						itemStyle: {
							areaColor: "rgba(10, 27, 120, 1)",
							borderWidth: 0.5,
							borderColor: 'rgba(82, 255, 253, 0.31)',
						},
						emphasis: {
							itemStyle: {
								areaColor: "rgb(26,48,169)",
							},
							label: {
								color: "#fff"
							}
						},
						data: data.map(function (n) {
							n.itemStyle = {
								areaColor: "rgba(10, 27, 120, 1)"
							}
							return n
						})
					},


					{
						name: "气泡",
						type: "scatter",
						coordinateSystem: "geo",
						symbol: "pin",
						symbolSize: 70,
						label: {
							show: true,
							formatter: function (node) {
								return "{num|" + node.value[2] + "}" + "\n" + "{city|" + node.name + "}"
							},
							rich: {
								num: {
									color: 'rgba(198, 79, 0, 1)',
									fontSize: 17,
									align: "center"
								},
								city: {
									color: 'rgba(198, 79, 0, 1)',
									fontSize: 10,
									align: "center"

								},
							}
						},
						itemStyle: {
							borderWidth: 2,
							borderColor: "#fff",
							color: "rgba(255, 232, 48, 1)",
							opacity: 1
						},
						zlevel: 6,
						data: data.map(function (n) {
							// if (n.value[2] > 100) {
							// 	n.label = {
							// 		fontSize: 19
							// 	}
							// }

							return n
						}),
						z: 2,
					}
				],

			};


			this.clear();
			this.setOption(option, !0);

			var me = this;

			//监听缩放事件
			this.on("georoam", function (param) {
				//如果是拖拽事件则退出
				// if (param.dy || param.dx) return;
				//获取最新的option配制
				var _option = me.getValue();
				//获取当前缩放比例zoom
				var _series = _option.series[0];
				var _zoom = _series.zoom;
				var _top = _series.top;
				var _left = _series.left;
				var _bottom = _series.bottom;
				var _height = _series.height;
				var _center = _series.center;
				var _z = _series.z;
				var _aspectScale = _series.aspectScale;
				// var _zoom = _series.zoom;
				//将缩放比例赋给新的option
				// _option.geo[0].z=_z;
				// _option.geo[0].zlevel=_zlevel;
				_option.geo[0].zoom = _zoom;
				_option.geo[0].center = _center;
				_option.geo[0].height = _height;
				_option.geo[0].bottom = _bottom;
				_option.geo[0].left = _left;
				_option.geo[0].top = _top;
				// 这里可以根据自己情况修改_option选项配制。。。。。。
				//清空
				// chart.clear();
				//更新修改后的option配制
				me.setOption(_option, true);
			});
		},
	});

	module.exports = Firebird.create(id, {id: id});
});